/**
 * Copyright (c) 2018 人人开源 All rights reserved.
 *
 * https://www.renren.io
 *
 * 版权所有，侵权必究！
 */

package com.evaluationSystem.util;

import com.evaluationSystem.exception.EvaluationException;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;

import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * 校验工具类
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0
 */
public class AssertUtils {

    public static void isBlank(String str, String params) {
        if (StringUtils.isBlank(str)) {
            throw new EvaluationException(params + "不能为空");
        }
    }

    public static void isNull(Object object, String params) {
        if (object == null) {
            throw new EvaluationException(params + "不能为空");
        }
    }

    public static void isArrayEmpty(Object[] array, String params) {
        if(ArrayUtils.isEmpty(array)){
            throw new EvaluationException(params + "不能为空");
        }
    }

    public static void isListEmpty(Collection<?> list, String params) {
        if(CollectionUtils.isEmpty(list)){
            throw new EvaluationException(params + "不能为空");
        }
    }

    public static void isMapEmpty(Map map, String params) {
        if(MapUtils.isEmpty(map)){
            throw new EvaluationException(params + "不能为空");
        }
    }

}